package com.south.base.test.arithmetic;

import org.junit.Test;

/**
 * @author Administrator
 * @date 2020/5/13 16:00
 */
public class SnowFlake {
    /**
     * 开始时间截 (2015-01-01)
     */
    private static final long TW_EPOCH = 1420041600000L;

    @Test
    public void test() {
        System.out.println(snowFlakeMaker(1, 1, 1));
        System.out.println(1 << 12);
    }

    public static long snowFlakeMaker(int userId, int merchantId, int seq) {
        return ((System.currentTimeMillis() - TW_EPOCH) << 22) //
                | (userId << 17) //
                | (merchantId << 12) //
                | seq;
    }
}
